﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;

namespace Classes
{
   public class Customer
   {
      #region Private Member Variables

      private String name, street, city, state, zip, phone;

      #endregion

      #region Properties

      public String Name            { get { return name; } }
      public String StreetAddress   { get { return street; } }
      public String City            { get { return city; } }
      public String StateName       { get { return state; } }
      public String StateAbbr       { get { return StateList.ConvertNameToAbbreviation(state); } }
      public String ZipCode         { get { return zip; } }
      public String PhoneNum        { get { return "(" + phone.Substring( 0, 3 ) + ") " + phone.Substring( 3, 3 ) + " - " + phone.Substring( 6 ); } }
      public String DBString
      {
         get
         {
            return String.Format("'{0}', '{1}', '{2}', '{3}', '{4}', '{5}'",
                name, street, city, state, zip, phone);
         }
      }

      #endregion

      #region Constructors
      
      /// <summary>
      /// Creates a new Customer from individual parameters.
      /// </summary>
      /// <param name="iName">Customer's Name</param>
      /// <param name="iStreet">Street Address</param>
      /// <param name="iCity">City</param>
      /// <param name="iState">State</param>
      /// <param name="iZip">Zip Code</param>
      /// <param name="iPhone">Customer's Primary Phone Number</param>
      public Customer (String iName, String iStreet, String iCity, String iState,
         String iZip, String iPhone)
      {
         name     = iName;
         street   = iStreet;
         city     = iCity;
         state    = iState;
         zip      = iZip;
         phone    = iPhone;
      }

      /// <summary>
      /// Creates a new Customer from a SQL Table Row.
      /// </summary>
      /// <param name="row">SqlDataReader containing a single row with customer information.</param>
      public Customer(SQLiteDataReader row)
      {
         name = (String) row["Name"];
         street = (String) row["Street"];
         city = (String) row["City"];
         state = (String) row["State"];
         zip = (String) row["Zip"];
         phone = (String) row["Phone"];
      }

      #endregion
   }
}
